using System;
using System.Collections.Generic;
using Slqj.Common;
using Shc.Sql;
namespace Slqj.Data
{
	[Serializable]
	public class ViewTicketOrderItemReport
		: BaseViewTicketOrderItemReport
	{		
		/// <summary>
        /// 根据条件查询单个实体
        /// </summary>
        /// <returns></returns>
        public static ViewTicketOrderItemReport Find(params Criterion[] criteria)
        {
            using (DbSession ss = DbManager.Current.OpenSession())
            {
                return DbManager.Current.Find<ViewTicketOrderItemReport>(criteria);
            }
        }
		
		/// <summary>
        /// 根据条件查询单个实体
        /// </summary>
        /// <returns></returns>
        public static ViewTicketOrderItemReport Find(DbSession ss,params Criterion[] criteria)
        {
			return DbManager.Current.Find<ViewTicketOrderItemReport>(ss,criteria);
        }

		/// <summary>
        /// 根据主键查询实体
        /// </summary>
		/// <param name="keys"></param>
        /// <returns></returns>
        public static ViewTicketOrderItemReport FindByPK(params object[] keys)
        {
            using (DbSession ss = DbManager.Current.OpenSession())
            {
                return DbManager.Current.FindPK<ViewTicketOrderItemReport>(ss, keys);
            }
        }
		
		/// <summary>
        /// 根据主键查询实体
        /// </summary>
		/// <param name="keys"></param>
        /// <returns></returns>
        public static ViewTicketOrderItemReport FindByPK(DbSession ss,params object[] keys)
        {
            return DbManager.Current.FindPK<ViewTicketOrderItemReport>(ss, keys);
        }
		
		/// <summary>
        /// 根据条件查询
        /// </summary>
		/// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewTicketOrderItemReport> FindAll(Order[] orders, params Criterion[] criteria)
        {
            IList<ViewTicketOrderItemReport> list=new List<ViewTicketOrderItemReport>();
            using (DbSession ss = DbManager.Current.OpenSession())
            {
                DbManager.Current.Query(ss, list, orders, criteria);
                return list;
            }
        }
		
		/// <summary>
        /// 根据条件查询
        /// </summary>
		/// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewTicketOrderItemReport> FindAll(params Criterion[] criteria)
        {
			return FindAll(new Order[0],criteria);
		}
		
		/// <summary>
        /// 根据条件查询
        /// </summary>
		/// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewTicketOrderItemReport> FindAll(Order[] orders,DbSession ss, params Criterion[] criteria)
        {
            IList<ViewTicketOrderItemReport> list=new List<ViewTicketOrderItemReport>();
            
            DbManager.Current.Query(ss, list, orders, criteria);
            return list;
        }
		
		/// <summary>
        /// 根据条件查询
        /// </summary>
		/// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewTicketOrderItemReport> FindAll(DbSession ss,params Criterion[] criteria)
        {
			return FindAll(new Order[0],ss,criteria);
		}
		
		/// <summary>
        /// 根据条件分页查询
        /// </summary>
        /// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewTicketOrderItemReport> FindByPage(int curPage,int pagesize,Order[] orders, 
			params Criterion[] criteria)
        {
            IList<ViewTicketOrderItemReport> list = new List<ViewTicketOrderItemReport>();
            using (DbSession ss = DbManager.Current.OpenSession())
            {
                DbManager.Current.Query(ss,list, curPage, pagesize, orders, criteria);
                return list;
            }
        }
		
		/// <summary>
        /// 根据条件分页查询
        /// </summary>
        /// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewTicketOrderItemReport> FindByPage(int curPage,int pagesize,params Criterion[] criteria)
        {
			return FindByPage(curPage,pagesize,new Order[0],criteria);
		}
		
		/// <summary>
        /// 根据条件分页查询
        /// </summary>
        /// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewTicketOrderItemReport> FindByPage(int curPage,int pagesize,Order[] orders, 
			DbSession ss ,params Criterion[] criteria)
        {
            IList<ViewTicketOrderItemReport> list = new List<ViewTicketOrderItemReport>();
            
            DbManager.Current.Query(ss,list, curPage, pagesize, orders, criteria);
            return list;
        }
		
		/// <summary>
        /// 根据条件分页查询
        /// </summary>
        /// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewTicketOrderItemReport> FindByPage(int curPage,int pagesize,
			DbSession ss ,params Criterion[] criteria)
        {
			return FindByPage(curPage,pagesize,new Order[0],ss,criteria);
		}

	    public string MemberAmount
	    {
	        get
	        {
                return (this.SalesGuidePrice - this.SettlementPrice).ToString("0.00");
	        }
	    }

	    public double test
	    {
	        get
	        {
	            return this.SalesGuidePrice - this.SettlementPrice;
	        }
	    }

	    public string SystemAmountDes
	    {
	        get
	        {
	            return SystemAmount.ToString("0.00") + "元/张";
	        }
	    }

	    public string SystemTotalAmount
	    {
	        get
	        {
                return (this.Quantity * this.SystemAmount).ToString("0.00");
	        }
	    }

	    public string MemberTotalAmount
	    {
	        get
	        {
                return ((this.SalesGuidePrice - this.SettlementPrice) * Quantity)
                    .ToString("0.00");
	        }
	    }

	    public string OrderIsVer
	    {
	        get
	        {
	            return IsVerify ? "入园" : "未入园";
	        }
	    }

        /// <summary>
        /// 结算总价
        /// </summary>
        public string SettlementTotalAmount
	    {
	        get
	        {
                return (Quantity * AttractionsAmount).ToString("0.00");
	        }
	    }

        /// <summary>
        /// 会员结算总价
        /// </summary>
        public string MemberSettlementTotalAmount
        {
            get
            {
                return (Quantity * SettlementPrice).ToString("0.00");
            }
        }

	    public string RefundStatus
	    {
	        get
	        {
                return RefundrDate == null ? "否" : "是";
	        }
	    }

        public DateTime ValidTime
        {
            get; set;
        }

	    public string RefundFee
	    {
	        get
	        {
                SystemConfig ticketConfig = SystemConfig.Load("cfg_ticket_refund");
                return RefundrDate == null ? string.Empty : (FieldUI.InFloat(ticketConfig.ConfigValue) * Quantity).ToString("0.00");
	        }
	    }

	    public string AttractionSettlementPrice
	    {
	        get
	        {
	            return this.AttractionsAmount.ToString("0.00") + "元/张";
	        }
	    }

        public string newOriginalPrice
        {
            get
            {
                return this.OriginalPrice.ToString("0.00");
            }
        }

        public string newOrgiSalesGuidePrice
        {
            get
            {
                return this.OrgiSalesGuidePrice.ToString("0.00");
            }
        }

        public string newSalesGuidePrice
        {
            get
            {
                return this.SalesGuidePrice.ToString("0.00");
            }
        }

        public string newTotalAmount
        {
            get
            {
                return this.TotalAmount.ToString("0.00");
            }
        }

        public string newSystemAmount
        {
            get
            {
                return this.SystemAmount.ToString("0.00");
            }
        }

        public string newRefundTotalAmount
        {
            get
            {
                return (Convert.ToDouble(this.RefundTotalAmount) > 0) ? Convert.ToDouble(this.RefundTotalAmount).ToString("0.00") : string.Empty;
            }
        }
        
	    public double RealSaleTotalAmount
	    {
	        get
	        {
	            return SalesGuidePrice*Quantity;
	        }
	    }
	}
}
